//
//  VVStackSpec.m
//  SideDemo
//
//  Created by zsp on 16/5/13.
//  Copyright 2016年 zsp. All rights reserved.
//

#import <Kiwi/Kiwi.h>
#import "VVStack.h"


SPEC_BEGIN(VVStackSpec)

describe(@"VVStack", ^{
    context(@"when assigned to 'Hello world'", ^{
        NSString *greeting = @"Hello world";
        it(@"should exist", ^{
            [[greeting shouldNot]beNil];
        });
        it(@"should equal to 'Hello world'", ^{
            [[greeting should] equal:@"Hello world"];
        });
    });
});

describe(@"VVStack2", ^{
    context(@"when created", ^{
        __block VVStack *stack = nil;
        beforeEach(^{
            stack=[VVStack new];
        });
        afterEach(^{
            stack=nil;
        });
        
        it(@"should have the class VVStack", ^{
            [[[VVStack class] shouldNot] beNil];
        });
        
        it(@"should exist", ^{
            [[stack shouldNot]beNil];
        });
        
        it(@"should be able to push and get top", ^{
            [stack push:2.3];
            [[theValue([stack top]) should]equal:theValue(2.3)];
            [stack push:4.3];
            [[theValue([stack top]) should]equal:theValue(4.3)];
        });
        
        it(@"should equal contains 0 element", ^{
            [[theValue([stack count]) should]beZero];
//            [[theValue([stack count]) should] equal:theValue(0)];
        });
        
        it(@"should raise a exception when pop", ^{
//            [[theBlock(^{
//                [stack pop];
//            }) should]raiseWithName:@"VVStackPopEmptyException"];
        });
    });
});

describe(@"VVStack3", ^{
    context(@"when new created and pushed 4.6", ^{
        __block VVStack *stack =nil;
        beforeEach(^{
            stack=[VVStack new];
            [stack push:4.6];
        });
        
        afterEach(^{
            stack =nil;
        });
        
        it(@"can be poped and the value equals 4.6", ^{
            [[theValue([stack pop]) should]equal:theValue(4.6)];
        });
        
        it(@"should contains 0 element after pop", ^{
            [stack pop];
            [[stack should]beEmpty];
        });
    });
    
});

SPEC_END
